<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2020/8/21 0021
 * Time: 上午 10:17
 */
require_once "./lib/DB.php";


$obj = (new DB());

//查询数据
$allData = $obj->query("info");
$obj->orderBy("create_time","DESC");
if (!empty($_GET["page"]) && !empty($_GET["limit"])){
    $obj->limit(($_GET["page"]-1)*$_GET["limit"],$_GET["limit"]);
}
$data = $obj->query("info");

//验证查询结果
if (isset($data["code"]) && $data["code"] == 2){
    echo json_encode(["code"=>2 ,"msg"=>$data["msg"]]);
}

//返回结果
echo json_encode(["code"=>0 ,"msg"=>"数据获取成功","count"=>count($allData),"data"=>$data]);